﻿<UserControl x:Class="Big3.Hitbase.MainControls.AlbumViewSymbols"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:dd="clr-namespace:Big3.Hitbase.Controls.DragDrop;assembly=Controls"
             xmlns:sr="clr-namespace:Big3.Hitbase.SharedResources;assembly=Big3.Hitbase.SharedResources"
             xmlns:misc="clr-namespace:Big3.Hitbase.Miscellaneous;assembly=Misc"
             xmlns:controls="clr-namespace:Big3.Hitbase.Controls;assembly=Controls"
             xmlns:local="clr-namespace:Big3.Hitbase.MainControls"
             mc:Ignorable="d" Name="albumViewSymbols"
             d:DesignHeight="300" d:DesignWidth="300">
    <UserControl.Resources>
        <ResourceDictionary>
            <local:SelectedIdsConverter x:Key="selectedIdsConverter" />

            <DataTemplate x:Key="AlbumViewItemDataTemplate">
                <Border Name="ItemContainer" MinHeight="110" BorderThickness="1" CornerRadius="5" BorderBrush="Transparent" TextElement.Foreground="{DynamicResource DefaultForeground}">
                    <StackPanel Name="GridRow" Background="Transparent" Orientation="Horizontal" >
                        <Grid Width="250" >
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="100" />
                                <ColumnDefinition Width="150"/>
                            </Grid.ColumnDefinitions>
                            <controls:ChoosePictureUserControl Grid.Column="0" ButtonText="" VerticalAlignment="Top" Height="80" Width="80" Margin="0,5,10,10" 
                                                                ImageFilename="{Binding ImageFilename, IsAsync=True}" Artist="{Binding Artist}" Title="{Binding Title}" 
                                                                CDID="{Binding ID}" DataBase="{Binding DataBase, ElementName=albumViewSymbols}"  CoverType="Front" 
                                                                ImageChanged="ChoosePictureUserControl_ImageChanged" />
                            <StackPanel Orientation="Vertical" Grid.Column="1">
                                <TextBlock Text="{Binding Path=Artist}" TextTrimming="CharacterEllipsis" Margin="0 3 0 2" />
                                <TextBlock Text="{Binding Path=Title}"  TextTrimming="CharacterEllipsis" Margin="0 3 0 2" />
                                <TextBlock Text="{Binding Path=Genre}"  TextTrimming="CharacterEllipsis" Margin="0 3 0 2" />
                                <TextBlock Text="{Binding Path=Year}"  TextTrimming="CharacterEllipsis" Margin="0 3 0 2" />
                                <TextBlock Text="{Binding Path=ArchiveNumber}"  TextTrimming="CharacterEllipsis" Margin="0 3 0 2" />
                            </StackPanel>
                        </Grid>
                    </StackPanel>
                </Border>
                <DataTemplate.Triggers>
                    <Trigger SourceName="ItemContainer" Property="IsMouseOver" Value="True">
                        <Setter TargetName="ItemContainer" Property="Background" >
                            <Setter.Value>
                                <LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
                                    <LinearGradientBrush.GradientStops>
                                        <!--<GradientStop Color="#F8FBFE" Offset="0" />
                                            <GradientStop Color="#E8F2FE" Offset="1" />-->
                                        <GradientStop Color="#90FFFFFF" Offset="0" />
                                        <GradientStop Color="#30FFFFFF" Offset="1" />
                                    </LinearGradientBrush.GradientStops>
                                </LinearGradientBrush>
                            </Setter.Value>
                        </Setter>
                        <Setter TargetName="ItemContainer" Property="BorderBrush" Value="#400000FF" />
                    </Trigger>
                </DataTemplate.Triggers>
            </DataTemplate>
            
        </ResourceDictionary>
    </UserControl.Resources>
    <ListBox x:Name="listBox" ItemTemplate="{StaticResource AlbumViewItemDataTemplate}"
                      ScrollViewer.VerticalScrollBarVisibility="Auto" 
                      ItemContainerStyle="{DynamicResource MyListBoxItemContainerStyle}"
                      AlternationCount="2" MouseDoubleClick="listBox_MouseDoubleClick"
             dd:DragDrop.IsDragSource="true" dd:DragDrop.IsDropTarget="false" dd:DragDrop.DragAdornerTemplate="{StaticResource AlbumViewItemDataTemplate}">
        <ListBox.ContextMenu>
            <ContextMenu DataContext="{Binding RelativeSource={RelativeSource Mode=Self}, Path=PlacementTarget}">
                <MenuItem Header="Löschen" Command="sr:HitbaseCommands.DeleteAlbum">
                    <MenuItem.Icon>
                        <Image Width="16" Height="16" Source="/Big3.Hitbase.SharedResources;component/Images/delete.png" />
                    </MenuItem.Icon>
                </MenuItem>
                <Separator />
                <MenuItem Header="Ins CD-Archiv übertragen" Command="sr:HitbaseCommands.SendCDToCDArchive" CommandParameter="{Binding SelectedItem.ID}">
                    <MenuItem.Icon>
                        <Image Width="16" Height="16" Source="/Big3.Hitbase.SharedResources;component/Images/SendToInternet.png" />
                    </MenuItem.Icon>
                </MenuItem>
                <MenuItem Header="Verliehen..." Command="sr:HitbaseCommands.CDLoaned" CommandParameter="{Binding SelectedItem.ID}">
                    <MenuItem.Icon>
                        <Image Width="16" Height="16" Source="/Big3.Hitbase.SharedResources;component/Images/LoanCD.png" />
                    </MenuItem.Icon>
                </MenuItem>
                <Separator />
                <MenuItem Header="Sofort spielen" Command="sr:HitbaseCommands.PlayAlbumNow" CommandParameter="{Binding SelectedItem.ID}">
                    <MenuItem.Icon>
                        <Image Width="16" Height="16" Source="/Big3.Hitbase.SharedResources;component/Images/PlayNowBlack.png" />
                    </MenuItem.Icon>
                </MenuItem>
                <MenuItem Header="Als nächstes spielen" Command="sr:HitbaseCommands.PlayAlbumNext" CommandParameter="{Binding SelectedItem.ID}">
                    <MenuItem.Icon>
                        <Image Width="16" Height="16" Source="/Big3.Hitbase.SharedResources;component/Images/PlayNextBlack.png" />
                    </MenuItem.Icon>
                </MenuItem>
                <MenuItem Header="Als letztes spielen" Command="sr:HitbaseCommands.PlayAlbumLast" CommandParameter="{Binding SelectedItem.ID}">
                    <MenuItem.Icon>
                        <Image Width="16" Height="16" Source="/Big3.Hitbase.SharedResources;component/Images/PlayLastBlack.png" />
                    </MenuItem.Icon>
                </MenuItem>
                <Separator />
                <MenuItem Header="Drucken" Command="sr:HitbaseCommands.PrintAlbum" CommandParameter="{Binding SelectedItem.ID}">
                    <MenuItem.Icon>
                        <Image Width="16" Height="16" Source="/Big3.Hitbase.SharedResources;component/Images/Print.png" />
                    </MenuItem.Icon>
                </MenuItem>
                <Separator />
                <MenuItem Header="In die Zwischenablage kopieren" Command="sr:HitbaseCommands.CopyToClipboard" CommandParameter="{Binding SelectedItems, Converter={StaticResource selectedIdsConverter}}">
                    <MenuItem.Icon>
                        <Image Width="16" Height="16" Source="/Big3.Hitbase.SharedResources;component/Images/Copy.png" />
                    </MenuItem.Icon>
                </MenuItem>
                <Separator />
                <MenuItem Header="Schreibweise anpassen" Command="sr:HitbaseCommands.AdjustSpelling" CommandParameter="{Binding SelectedItem.ID}">
                    <MenuItem.Icon>
                        <Image Width="16" Height="16" Source="/Big3.Hitbase.SharedResources;component/Images/AdjustSpelling.png" />
                    </MenuItem.Icon>
                </MenuItem>
                <Separator />
                <MenuItem Header="Eigenschaften" Command="sr:HitbaseCommands.OpenAlbum" CommandParameter="{Binding SelectedItem.ID}">
                    <MenuItem.Icon>
                        <Image Width="16" Height="16" Source="/Big3.Hitbase.SharedResources;component/Images/Properties.png" />
                    </MenuItem.Icon>
                </MenuItem>
            </ContextMenu>
        </ListBox.ContextMenu>
        <ListBox.ItemsPanel>
            <ItemsPanelTemplate>
                <misc:VirtualizingTilePanel ChildSize="250,110"/>
            </ItemsPanelTemplate>
        </ListBox.ItemsPanel>
        <ListBox.Template>
            <ControlTemplate>
                <ScrollViewer x:Name="ScrollViewer" Padding="{TemplateBinding Padding}">
                    <ItemsPresenter />
                </ScrollViewer>
            </ControlTemplate>
        </ListBox.Template>
    </ListBox>
</UserControl>
